<template>
  <div id="app">
    <v-header :seller="seller"></v-header>
    <v-nav></v-nav>
    <router-view :seller="seller"></router-view>
  </div>
</template>

<script>
  import Header from './components/Header/Header';
  import Nav from './components/Nav/Nav';
  import Goods from './components/Goods/Goods';
  import Seller from './components/Seller/Seller';
  import Ratings from './components/Ratings/Ratings';

  const NO_ERR = 0;

  export default {
    data() {
      return {
        seller: {},
        goods: [],
        ratings: []
      }
    },
    components: {
      'v-header': Header,
      'v-nav': Nav,
      'v-goods': Goods,
      'v-ratings': Ratings,
      'v-seller': Seller
    },
    created() {
      fetch('/api/seller').then((res) => {
        return res.json()
      }).then(resp => {
        if (resp.errno === NO_ERR) {
          this.seller = resp.data;
        }
      });

      // fetch('/api/goods').then((res) => {
      //   return res.json()
      // }).then(resp => {
      //   if (resp.errno === NO_ERR) {
      //     this.goods = resp.data;
      //     console.log(this.goods)
      //   }
      // });
      //
      // fetch('/api/ratings').then((res) => {
      //   return res.json()
      // }).then(resp => {
      //   if (resp.errno === NO_ERR) {
      //     this.ratings = resp.data;
      //   }
      // });

    }
}
</script>

<style>
</style>
